home *** CD-ROM | disk | FTP | other *** search
- /*----------- SineWave.c -------------*/
- /*A sample external function for XDemo.
- by Mark Lankton, 1989 for MacTutor
- */
- #include <types.h>
- #include <resources.h>
- #include <OSUtils.h>
- #include <OSEvents.h>
- #include <SANE.h>
- #include <math.h>
- #include <stdlib.h>
-
- typedef struct XTRABlock{
- int dataLength;
- short *theData;
- }XTRABlock,*XTRABlockPtr,**XTRABlockHandle;
-
- #define TRUE 0xFF;
- #define FALSE 0x00;
-
- #define twopi (3.14159265358979 * 2)
- /************************** prototype *********************/
- pascal Boolean SineWave(XTRABlock *blockPtr);
-
- /************************** function **********************/
- pascal Boolean
- SineWave(blockPtr)
- XTRABlock *blockPtr;
- {
- int i;
- extended temp;
-
- for(i = 0; i < blockPtr->dataLength;i++)
- {
- temp = (extended)(i * (twopi / 100));
- *(blockPtr->theData + i) = (short)rint(sin(temp) * 20);
- }
- return TRUE;
-
- }